home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / cstdio.arc / SRC.ARC / STRCHR.A < prev    next >
Text File  |  1985-08-20  |  638b  |  33 lines

  1. ;    strchr.a - find first occurrence of character in string.
  2. ;    (C) Copyright 1985 Cray Research Inc. - All Rights Reserved.
  3. ;    G. R. Mansfield.  85/08/20.
  4. ;    Ver 1.0-5820.
  5.  
  6.  
  7.     cseg
  8.     
  9.     public    strchr_
  10.     public    index_
  11.     
  12. ;    char *strchr(s, c)    /* return pointer to first occurrence of c */
  13. ;    char *index(s, c)    /* in s NULL if c is not in s */
  14. ;    char *s;
  15. ;    int c;
  16.  
  17. strchr_:
  18. index_:
  19.     mov    bx,sp
  20.     mov    si,[bx+2]    ; s
  21.     mov    ah,[bx+4]    ; c
  22. stc1:    lodsb            ; next character in s
  23.     or    al,al
  24.     jz    stc2        ; end of string
  25.     cmp    al,ah
  26.     jnz    stc1        ; loop if not found
  27.     xchg    ax,si        ; pointer to c
  28.     dec    ax
  29.     ret
  30.  
  31. stc2:    cbw            ; null pointer
  32.     ret
  33.